#include <stdio.h>
#include <QApplication>
#include "UdpReceiver.h"
#include "LidarProcesser.h"

int ui(int argc, char **argv)
{
    QApplication app(argc, argv);

    for (int i = 1; i < 5; i++)
    {
        std::string datFile = "/home/school/cxz/Projects/isc-lib-lidar/examples/example02/files/" + std::to_string(i) + ".dat";
        std::cout << datFile << std::endl;
        std::vector<std::string> udpPorts;
        std::string port = "236" + std::to_string(i);
        udpPorts.push_back(port);

        LidarListener *lidarListener = new LidarListener(nullptr, port, datFile);
        lidarListener->setWindowTitle("Qt Example");
        lidarListener->setGeometry(100, 100, 1200, 800);

        UdpReceiver *udpReceiver = new UdpReceiver(udpPorts);
        udpReceiver->subscribe((void *)lidarListener);

        lidarListener->show();
    }
    int res = app.exec();
    return res;
}

int main(int argc, char **argv)
{
    return ui(argc, argv);
}